import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'paper_wave_loading.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // 横屏显示
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
  // 全屏显示
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
  runApp(const WaveLoadingApp());
}

class WaveLoadingApp extends StatelessWidget {
  const WaveLoadingApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'PicMan',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(primarySwatch: Colors.blue),
        home: Scaffold(
          body: Padding(
            padding: const EdgeInsets.only(top: 58, left: 20),
            child: Center(
              child: Wrap(
                spacing: 20,
                runSpacing: 20,
                children: buildChildren(),
              ),
            ),
          ),
        ));
  }

  List<Widget> buildChildren() => List.generate(9, (v) => 0.1 * v + 0.1)
      .map((e) => WaveLoading(
            isOval: (e * 10).toInt().isEven, // 是否椭圆裁切
            progress: e, // 进度
            waveHeight: 3, //波浪高
            color: [
              Colors.blue,
              Colors.red,
              Colors.green
            ][(e * 10).toInt() % 3], //颜色
          ))
      .toList();
}
